import request from '@/utils/request'

/**
 * 获取缓存统计信息
 */
export function getCacheStats() {
  return request.get('/monitor/cache/stats')
}

/**
 * 获取缓存列表
 */
export function getCacheList() {
  return request.get('/monitor/cache/list')
}

/**
 * 获取Redis信息
 */
export function getRedisInfo() {
  return request.get('/monitor/cache/redis/info')
}

/**
 * 清除指定缓存
 */
export function clearCache(cacheName: string) {
  return request.delete(`/monitor/cache/clear/${cacheName}`, {}, {
    showLoading: true,
    showSuccess: true,
    successMsg: '缓存清除成功',
  })
}

/**
 * 清除所有缓存
 */
export function clearAllCache() {
  return request.delete('/monitor/cache/clear/all', {}, {
    showLoading: true,
    showSuccess: true,
    successMsg: '所有缓存清除成功',
  })
}

/**
 * 重置缓存统计
 */
export function resetCacheStats() {
  return request.post('/monitor/cache/reset', {}, {
    showLoading: true,
    showSuccess: true,
    successMsg: '缓存统计重置成功',
  })
}

/**
 * 获取缓存键值
 */
export function getCacheKeys(cacheName: string) {
  return request.get(`/monitor/cache/keys/${cacheName}`)
}

